scrolledwindow: Calculate indicator coords relative to scrolledwindow
authorTimm Bäder <mail@baedert.org>
Tue, 9 May 2017 17:26:27 +0000 (19:26 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 25 May 2017 14:25:59 +0000 (16:25 +0200)
The event coordinates we get are relative to the scrolledwindow
coordinates.

gtk/gtkscrolledwindow.c

index c3d437de011a122afd48f13a449da693e6fb4358..2eef2bf89866e68825e33cee309705156fba7ce0 100644 (file)
@@ -1083,14 +1083,21 @@ event_close_to_indicator (GtkScrolledWindow *sw,
 {
   GtkScrolledWindowPrivate *priv;
   GtkAllocation indicator_alloc;
+  GtkAllocation sw_alloc;
   gdouble x, y;
   gint distance;
 
   priv = sw->priv;
 
+  gtk_widget_get_allocation (GTK_WIDGET (sw), &sw_alloc);
   gtk_widget_get_allocation (indicator->scrollbar, &indicator_alloc);
   gdk_event_get_coords (event, &x, &y);
 
+  /* Make indicator alloc relative to scrolledwindow alloc, which is also
+   * what the event coords are relative to */
+  indicator_alloc.x -= sw_alloc.x;
+  indicator_alloc.y -= sw_alloc.y;
+
   if (indicator->over)
     distance = INDICATOR_FAR_DISTANCE;
   else